define([], function () {
    var app = angular.module("App.home");
    app.controller("projects.addnewCtrl", ["$scope", "$state", "$timeout", "Project", "showMsg", "corporationList", function ($scope, $state, $timeout, Project, showMsg, corporationList) {
        $scope.creating = false;
        $scope.item = {};
        $scope.lineNameList = (function () {
            var arr = [];
            for (var i = 1; i <= 25; i++)
                arr.push(i.toString() + "号线");
            return arr;
        })();
        $scope.cityNameList = ["上海", "南京", "杭州", "慈溪", "其他"];
        $scope.projectTypeList = [{
            name: "地铁监护",
            value: "MetroMonitor"
        }, {
                name: "公路隧道",
                value: "RoadTunnelMonitor"
            }, {
                name: "重点段监护",
                value: "CriticalSectionMonitor"
            }, {
                name: "长期测量",
                value: "LongTermSubElevation"
            }, {
                name: "长期收敛",
                value: "LongTermSubChord"
            }, {
                name: "大众汽车",
                value: "Volkswagen"
            }];
        $scope.corporationList = corporationList;
        $scope.addProject = function () {
            $scope.creating = true;
            var obj = angular.copy($scope.item);
            obj.corporation = obj.corporation.shortName;
            Project
                .addProject(obj)
                .then(function (data) {
                    showMsg("新建项目成功", "info");
                    $state.reload();
                }, function (reason) {
                    showMsg("新建项目失败", "alert");
                });
        };
    }]);
});
